/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.lis.model.newmodel;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;

/**
 *
 * @author cxhd
 */
@SuppressWarnings("serial")
public class LisUnit extends Model<LisUnit> {
    public static final LisUnit lisUnitdao=new LisUnit();
    
      public void deleteUnit(int PK) throws Exception{
        Db.use("mysql").update("delete from lis_unit where PK="+PK);

    }
    public void saveUnit(Controller con) throws Exception{
 
             set("UNITNAME", con.getPara("UNITNAME"))
                .set("UNITCHINA", con.getPara("UNITCHINA"))
                .save();
               
    }
    public void updateUnit(Controller con){
        findById(Integer.valueOf(con.getPara("PK")))
                . set("UNITNAME", con.getPara("UNITNAME"))
                .set("UNITCHINA", con.getPara("UNITCHINA"))
                .update();
    }
//    public String getUnit(){
//         List<Record> list=Db.use("mysql").find("select * from lis_ksdm limit 0,10");
//        String  value = "1";
//        if(list.size()>0){
//       value = (Integer.parseInt(Db.use("mysql").findFirst("SELECT MAX(KSDM) as id from lis_ksdm ").get("id") + "") + 1) + "";
//        }
//      return value;
//    }
}
